package cn.ld.module.system.service.logger;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.common.util.object.BeanUtils;
import cn.ld.module.system.api.logger.dto.OperateLogCreateInDTO;
import cn.ld.module.system.api.logger.dto.OperateLogPageInDTO;
import cn.ld.module.system.controller.admin.logger.vo.operatelog.OperateLogPageInVO;
import cn.ld.module.system.dal.entity.logger.OperateLogEntity;
import cn.ld.module.system.dal.mapper.logger.OperateLogMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * 操作日志 Service 实现类
 *
 * @author 蓝盾
 */
@Service
@Validated
@Slf4j
public class OperateLogServiceImpl implements OperateLogService {

    @Resource
    private OperateLogMapper operateLogMapper;

    @Override
    public void createOperateLog(OperateLogCreateInDTO createInDTO) {
        OperateLogEntity log = BeanUtils.toBean(createInDTO, OperateLogEntity.class);
        operateLogMapper.insert(log);
    }

    @Override
    public PageResult<OperateLogEntity> getOperateLogPage(OperateLogPageInVO pageInVO) {
        return operateLogMapper.selectPage(pageInVO);
    }

    @Override
    public PageResult<OperateLogEntity> getOperateLogPage(OperateLogPageInDTO pageInDTO) {
        return operateLogMapper.selectPage(pageInDTO);
    }

}
